package com.mm.cme.kotlin_001.level02.i_001_class

import com.mm.cme.kotlin_001.utils.pl

/**
 * Descriptions：类定义，参考Java中的JavaA
 * <p>
 * Author：ChenME
 * Date：2017/7/16
 * Email：ibelieve1210@163.com
 */

class X

class A {
    var b = 0
        get() {
            pl("Kotlin someone tries to get b.")
            return field
        }
        set(value) {
            pl("Kotlin someone tries to set b.")
            field = value
        }

    lateinit var c: String
    lateinit var d: X
    val e: X by lazy {
        pl("创建了X")
        X()
    }
}

fun main(args: Array<String>) {
    val a = A()
    pl("init a")
    pl(a.b)
    pl(a.e)

    a.d = X()
    pl(a.d)

//    pl(a.c) // 报错！使用之前没有对其进行初始化！！！
}